<?php
$_SESSION ['shop_return_url'] = $_SERVER ['REQUEST_URI'];
if ((isset ( $_GET ['cateSelect'] ) && ( int ) $_GET ['cateSelect'] > 0)) {
	$changeCate = $_GET ['cateSelect'];
	// echo $changeCate;
	$sql2 = $changeCate;
	$qstring = "cateSelect=$changeCate";
	// echo $sql2;
} else {
	$changeCate = 0;
	$sql2 = '';
	$qstring = '';
}
$sql3 = "SELECT * FROM tblcategory WHERE parent_id = 0
		ORDER BY ordering";
$result3 = mysql_query ( $sql3);
?>
<div class="breadcrumb">
	<a href="<?php echo base_url_admin;?>"><?php echo $lang['HOME'];?></a> ::<?php echo $lang['CAT_MANAGE'];?>
</div>
<div class="box">
	<?php
		$message = (isset($_GET['msg']) ? $_GET['msg'] : '');
		switch($message){
			case 'delete_success' :
			$messages = '<div class="success" id="success">'. $lang['MSG_DELETE_SUCCESS'] . '</div>';
			break;
			case 'add_success':
			$messages = '<div class="success" id="success">' . $lang['ADD_CATEGORY_SUCCESS'] . '</div>';
			break;
			case 'update_success' :
			$messages = '<div class="success" id="success">' . $lang['MSG_UPDATE_SUCCESS'] . '</div>';
			break;
		}
		echo '<div class="message_contain">';
			echo @$messages;
		echo '</div>';
	?>
	<div class="heading">
		<h1>
			<img src="../templates/image/category.png" alt="" />
			<?php echo $lang['CAT_MANAGE'];?>
	</h1>
		<div class="buttons">
			<input class="button" type="button" name="btnadd"
				value="<?php echo $lang['ADD_NEW']; ?>"
				onClick="javascript:window.location.href='index.php?view=add&amp'; return false;" />&nbsp;&nbsp;&nbsp;
			<input class="button" type="button" name="btnedit"
				value="<?php echo $lang['EDIT']; ?>"
				onclick="EditSelected(document.frmlist,'<?php echo htmlspecialchars(getAllGetParams(array('action','view','id')));?>','No item is selected for Editing!','Category(s)','Edit')" />&nbsp;&nbsp;&nbsp;
			<input class="button" type="button" name="btnpublish"
				value="<?php echo $lang['PUBLISH']; ?>"
				onClick="publishSelected(document.frmlist,'','No items select',1,'Category(s)','process');" />&nbsp;&nbsp;&nbsp;
			<input class="button" type="button" name="btnunpublish"
				value="<?php echo $lang['UNPUBLISH']; ?>"
				onClick="publishSelected(document.frmlist,'','No items select',0,'Category(s)','process');" />&nbsp;&nbsp;&nbsp;
			<input class="button" type="button" name="btndelete" id="deleteCategory"
				value="<?php echo $lang['MY_DEL']; ?>"
				onclick="multiDelete()" /><br />
		</div>
	</div>
	<div class="content">
		<form action="process.php?action=muliDelete" method="post" name="frmlist" id="multidelete">
			<div style="clear: both;">&nbsp;</div>
			<table class="list" cellpadding="4" cellspacing="2">
				<thead>
					<tr>
						<td width="25" class="left"><?php echo $lang['ID']; ?></td>
						<td width="25"><input type="checkbox" name="chkall" id="chkall" onClick="checkAll(this.form,this.checked)" style="cursor: pointer;"></td>
						<td align="left"><?php echo $lang['CATEGORY_NAME']; ?> </td>
						<td><?php echo $lang['STATUS'];?></td>
					</tr>
				</thead>
				<tbody>
				<?php
				if ((isset ( $_GET ['cateSelect'] ) && ( int ) $_GET ['cateSelect'] > 0)) {
					cat_by_cat ();
				} else {
					cat_by_cat ();
					// post_all_cat();
				}

				?>
				</tbody>
			</table>
			<div class="row-fluid">
				<div class="span7">
					<div class="wp-pagenavi">
						<div class="clear"></div>
					</div>
				</div>
			</div>
		</form>
		<form method="post" name="frmOrder" action="save_order.php?table=tblcategory" target="fraorder">
			<input type="hidden" name="hid_order" id="hid_order" />
		</form>
		<iframe id="fraorder" name="fraorder" style="display: none"></iframe>
	</div>
	<!--<div class="row">-->

</div>